package inge_soft.gestoriusNuevo.persistence.DAO.implementation;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import inge_soft.gestoriusNuevo.persistence.DAO.abstraction.ICategoriaDAO;
import inge_soft.gestoriusNuevo.persistence.entity.implementation.Categoria;

@Repository("categoriaDAO")
public class CategoriaDAO implements ICategoriaDAO {

	@PersistenceContext
	private EntityManager entityManager;
	
	@SuppressWarnings("unchecked")
	@Transactional(readOnly = true)
	public List<Categoria> obtenerTodasCategoriasEventos() throws DataAccessException {
		Query query = entityManager.createQuery("SELECT c FROM Categoria c");
		return query.getResultList();
	}

}
